//上级栏目
$(function(){
     	var setting2 = {
			check: {
				enable: true
			},
			data: {
				simpleData: {
					enable: true
				}
			}
		};

		var zNodes2 ;
		var code2;
		function setCheck() {

			var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
					py = $("#py").attr("checked")? "p":"",
					sy = $("#sy").attr("checked")? "s":"",
					pn = $("#pn").attr("checked")? "p":"",
					sn = $("#sn").attr("checked")? "s":"",
					type = { "Y":py + sy, "N":pn + sn};
			zTree.setting.check.chkboxType = type;
			showCode('setting.check.chkboxType = { "Y" : "' + type.Y + '", "N" : "' + type.N + '" };');
		}
		function showCode(str) {
			if (!code2) code2 = $("#code");
			code2.empty();
			code2.append("<li>"+str+"</li>");
		}
		function fuzhi(data){
			zNodes2=eval("("+data+")");
			$.fn.zTree.init($("#treeDemo"), setting2, zNodes2);
			setCheck();
			$("#py").bind("change", setCheck);
			$("#sy").bind("change", setCheck);
			$("#pn").bind("change", setCheck);
			$("#sn").bind("change", setCheck);

		}
		var zNodes2 =[
			{id:4, pId:0, name:"内科",nocheck:'true'},
			{id:41, pId:4, name:"心率",nocheck:'true'},
			{id:42, pId:4, name:"心音",nocheck:'true'},
			{id:43, pId:4, name:"腹部",nocheck:'true'},
			{id:44, pId:4, name:"脾脏",nocheck:'true'},
			{id:5, pId:0, name:"外科",nocheck:'true'},
			{id:51, pId:5, name:"皮肤",nocheck:'true'},
			{id:52, pId:5, name:"脊柱",nocheck:'true'},
			{id:53, pId:5, name:"四肢与关节",nocheck:'true'},
			{id:54, pId:5, name:"乳腺",nocheck:'true'},
			{id:6, pId:0, name:"皮肤",nocheck:'true'},
			{id:7, pId:0, name:"脊柱",nocheck:'true'},
			{id:8, pId:0, name:"四肢与关节",nocheck:'true'},
			{id:9, pId:0, name:"乳腺",nocheck:'true'}
		];

		$(document).ready(function(){
			$.fn.zTree.init($("#tree2"), setting2, zNodes2);
			var treeObj = $.fn.zTree.getZTreeObj("tree");
			treeObj.expandAll(true);
		});
     })

//新增异常指标
$(".bancgud").on('click','.add_zhibiao',function() {
	var add_zb = '<div class="form-group">' +
		'<div class="col-lg-8 col-lg-offset-2">' +
		'<div class="input-group">' +
		'<input type="text" class="form-control" disabled>' +
		'<span class="input-group-btn">' +
		'<a href="#zhibiao" data-toggle="modal" class="btn btn-default shiny" style="line-height: 20px">选择</a>' +
		'</span>' +
		'</div>' +
		'</div>' +
		'<div class="col-lg-2 controls">' +
		'<span class="square min_zhibiao"><i class="fa fa-minus"></i></span>' +
		'</div>' +
		'</div>';
	$(this).parent().parent().after(add_zb);
	//删除异常指标
	$(".min_zhibiao").click(function() {
		$(this).parent().parent().remove();
	})
})

//组合异常新增指标项
	$(".bancgud").on('click','.add_content',function(){
	var zuhe = '<div class="zuhe_content">' +
		'<div class="form-group">' +
		'<label class="col-lg-2 control-label">异常名称</label>' +
		'<div class="col-lg-8">' +
		'<input type="text" class="form-control">' +
		'</div>' +
		'</div>' +
	
		'<div class="form-group">' +
		'<label class="col-lg-2 control-label">指标项</label>' +
		'<div class="col-lg-8">' +
		'<div class="input-group">' +
		'<input type="text" class="form-control" disabled>' +
		'<span class="input-group-btn">' +
		'<a href="#zhibiao" data-toggle="modal" class="btn btn-default shiny" style="line-height: 20px">选择</a>' +
		'</span>' +
		'</div>' +
		'</div>' +
		'<div class="col-lg-2 controls">' +
		'<span class="square add_zhibiao"><i class="fa fa-plus"></i></span>' +
		'</div>' +
		'</div>' +
		'<div class="form-title"></div>' +
		'</div>';
		$(this).before(zuhe);
})


//删除table>tr
$(".removeClass").on('click', function() {
	removeClass(this)
});
function removeClass(_this) {
	$(_this).parent().parent().remove();
}
	
